<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black"><span class="font-bold"><img
                            src="img/simpleicons/kubernetes_name_blue.svg" width="160" height="25"></span></h1>
                    <small class="text-muted">服务详情</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <div class="panel panel-default" ng-controller="serviceCtrl">
                    <div class="panel-body">

                        <form class="form-inline" role="form">
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">名称</span>
                                    <input type="text" class="form-control" ng-model="queryName" placeholder="服务名称">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">集群/命名空间</span>
                                    <ui-select ng-model="nowNamespace.selected" theme="bootstrap"
                                               ng-disabled="disabled">
                                        <ui-select-match placeholder="选择命名空间">
                                            {{$select.selected.clusterName}}/{{$select.selected.namespace}}
                                        </ui-select-match>
                                        <ui-select-choices group-by="'clusterName'"
                                                           repeat="item in namespaceList | filter: $select.search">
                                            <div ng-bind-html="item.namespace | highlight: $select.search"></div>
                                        </ui-select-choices>
                                    </ui-select>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">端口协议</span>
                                    <select class="form-control" ng-model="nowServicePort.selected"
                                            ng-options="portType.code as portType.name for portType in servicePortType">
                                        <option value="">--请选择--</option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <button type="button" class="btn btn-info" ng-click="doQuery()"><span
                                        class="glyphicon glyphicon-search"></span>搜索
                                </button>
                                <button type="button" class="btn btn-info" ng-click="reSet()"><span
                                        class="glyphicon glyphicon-repeat"></span>重置
                                </button>
                                <button type="button" class="btn btn-success" ng-click="sync()"
                                        ng-if="contains(authPoint, '/kubernetes/save')">
                                    <i class="fa fa-spin fa-spinner" ng-show="btnSyncDisabled"></i>
                                    <i class="glyphicon glyphicon-refresh" ng-show="!btnSyncDisabled"></i>同步
                                </button>
                            </div>
                        </form>

                        <div class="panel panel-default" style="margin-top: 5px;">
                            <div class="panel-body">
                                <div>
                                    <table class="table table-hover table-bordered table-striped">
                                        <thead>
                                        <tr>
                                            <td>服务名</td>
                                            <td>服务器组</td>
                                            <td>服务类型/集群IP</td>
                                            <td class="col-md-4">端口列表</td>
                                            <td>创建时间</td>
                                            <td ng-if="contains(authPoint, '/kubernetes/save')">操作</td>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="item in pageData">
                                            <td>
                                                <b style="color: #2b669a">{{item.name}}</b>
                                                <br/>
                                                <b style="color: #777">{{item.namespace.clusterName}}/{{item.namespace.namespace}}</b>
                                            </td>
                                            <td>
                                                <b style="color: #2b669a">{{item.serverGroupName}}</b>
                                            </td>
                                            <td>
                                                <b style="color: #777">{{item.serviceType}}/{{item.clusterIP}}</b>
                                            </td>
                                            <td>
                                                <div class="col-md-12" ng-repeat="servicePort in item.servicePortList">
                                                    <span class="label"
                                                          style="background-color: #00a8f3; color: white;">{{servicePort.name}}</span>
                                                    <span class="label" style="background-color: #777; color: white;"
                                                          ng-if="servicePort.nodePort !=0">NodePort:{{servicePort.nodePort}}</span>
                                                    <span class="label" style="background-color: #777; color: white;"
                                                          ng-if="servicePort.port !=0">Port:{{servicePort.port}}</span>
                                                    <span class="label" style="background-color: #777; color: white;"
                                                          ng-if="servicePort.targetPort !=0">TargetPort:{{servicePort.targetPort}}</span>
                                                </div>
                                            </td>
                                            <td>{{(item.gmtModify == null || item.gmtModify == '') ? item.gmtCreate
                                                : item.gmtModify}}
                                            </td>
                                            <td ng-if="contains(authPoint, '/kubernetes/save')">
                                                <button ng-click="editService(item)"
                                                        class="btn btn-xs"
                                                        style="background-color: #2e6da4; color: white;">
                                                    <span class="glyphicon glyphicon-edit"></span>编辑
                                                </button>
                                                <br/>
                                                <button ng-click="delService(item.id)"
                                                        class="btn btn-xs"
                                                        style="background-color: red; color: white;">
                                                    <span class="glyphicon glyphicon-remove"></span>删除
                                                </button>

                                            </td>
                                        </tr>
                                        </tbody>
                                        <tfoot>
                                        <tr>
                                            <td colspan="9">
                                                <ul style="margin: 0px; float: right;" uib-pagination
                                                    total-items="totalItems" ng-model="currentPage"
                                                    items-per-page="pageLength" max-size="10"
                                                    ng-change="pageChanged()" previous-text="&lsaquo;"
                                                    next-text="&rsaquo;"></ul>
                                            </td>
                                        </tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>

<script type="text/ng-template" id="serviceInfo">
    <div ng-include="'tpl/modal/kubernetes/service_info_modal.html'"></div>
</script>

